<?php
namespace app\admin\model\trading;
use think\facade\Db;
use app\admin\common;

class OrderAudit{
	
	public function findAuditOrder($_where,$_field){
		return Db::name("opus")->alias("o")
			->join("opus_number n","o.id=n.opus_id")
			->join("user u ","u.id=n.owner_uid")
			->join("opus_series s","o.series_id=s.id and n.each_price >= s.audit_money")
			->where($_where)
			->field($_field)
			->find();
	}
	public function selectAuditOrder($_where,$_field,$_limit,$_order)
	{
		$_data=Db::name("opus")->alias("o")
			->join("opus_number n","o.id=n.opus_id")
			->join("user u ","u.id=n.owner_uid")
			->join("opus_series s","o.series_id=s.id and n.each_price >= s.audit_money")
			->where($_where)
			->field($_field)
			->limit(current($_limit),end($_limit))
			->order($_order)
			->select();
		return empty($_data)?:$_data->toArray();
	}
	public function selectAutomaticAuditOrder($_where,$_field)
	{
		$_data=Db::name("opus")->alias("o")
			->join("opus_number n","o.id=n.opus_id")
			->join("user u ","u.id=n.owner_uid")
			->join("opus_series s","o.series_id=s.id and n.each_price < s.audit_money")
			->where($_where)
			->field($_field)
			->select();
		return empty($_data)?:$_data->toArray();
	}
	
	public function selectNumberAuditStatus($_where,$_field){
		$_data=Db::name("opus_number")->where($_where)->field($_field)->select();
		return empty($_data)?:$_data->toArray();
	}
	
	public function updateData($_up,$_where){
		return Db::name("opus_number")->where($_where)->update($_up);
	}
	
}
?>